Page({
  data: {
    hot: [{
      name: "0chain(ZCN)",
      sx: "ZCN"
    }, {
      name: "0x(ZRX)",
      sx: "ZRX"
    }, {
      name: "1World(1WO)",
      sx: "1WO"
    }, {
      name: "300Token(300)",
      sx: "300"
    }]
  },
  onLoad: function(options) {
    this.data.cashIdx = options.cashIdx;
    this.data.conversion = options.conversion;
  },
  // 点击币种将上一页所选持币项改为所选币种项
  changCur: function (e) {
    let pages = getCurrentPages();
    let prevPage = pages[pages.length - 2]; //上一页
    let conversion = this.data.conversion; //上一页点击换算
    let prevArr = prevPage.data.currencyArr; //上一页的数组
    
    let hot = this.data.hot; //当前页数组
    let cashIdx = this.data.cashIdx; //上一页点击持币的数组下标
    let thisArrIdx = e.target.dataset.index; //当前页点击的数组下标

    if (cashIdx){
      prevArr[cashIdx] = {
        name: hot[thisArrIdx].name,
        sx: hot[thisArrIdx].sx
      };
      prevPage.setData({
        currencyArr: prevArr
      })
      wx.navigateBack({
        url: "../calculator/calculator",
      })
    } else if (conversion){
      prevPage.setData({
        conversion: hot[thisArrIdx].sx
      })
      wx.navigateBack({
        url: "../calculator/calculator",
      })
    }
  }
})